//
//  ModalViewController.m
//  NavBar
//
//  Created by Thiago on 23/07/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "ModalViewController.h"



@implementation ModalViewController

@synthesize statAttributes;

//static NSMutableArray *statValues = nil;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	
	self.title = [[NSString alloc] initWithString:@"Stats"];
	
	//self.statValues = [NSMutableArray array];
	
	//Only load them once
	if (!statAttributes)
	{
		//Only temporarily listed here
		statAttributes = [[NSMutableArray alloc] initWithObjects:@"Vital Info", @"Name", @"Level", @"Hitpoints", @"Turns", 
						           @"Attack", @"Defense", @"Spirits", @"Race", @"Personal Info", @"Gold", 
						           @"Gems", @"Experience", @"Equipment Info", @"Weapon", @"Armor", @"Buffs", nil];
    }
	

	/*
	for (NSString *statAttribute in statAttributes)
	{
		[self.statValues];
	}
	*/
	
	UITableView *tableView = [[UITableView alloc] init];
	tableView.delegate = self;
	tableView.dataSource = self;
	tableView.rowHeight = (CGFloat) 24.0;
	self.view = tableView;
	[tableView reloadData];
	[tableView release];
} 



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

#pragma mark -
#pragma mark UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

	return statAttributes.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
	
	static NSString *kCellIdentifier = @"cellID";
	
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
	if (!cell)
	{
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kCellIdentifier] autorelease];
		//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	}
	
	cell.textLabel.text = [statAttributes objectAtIndex:indexPath.row];
	
	return cell;
}	


#pragma mark -
#pragma mark UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   [self dismissModalViewControllerAnimated:YES];
}


@end
